<div id="bloc_description" style="margin-top:10px;">
	<form action="?nom=<?php echo $nom; ?>&amp;page=liste_ajouter" name="ajouter" id="formulaire" method="POST">
		<input type="hidden" name="add" value="1" />	
		<div class="entete_liste_config">
			<div class="titre">DETAILS DE L'ABONN&Eacute;</div>
			<div class="fonction_valider">
				<a href="#" onclick="document.getElementById('formulaire').submit();">VALIDER</a>
			</div>
		</div>
		<table width="100%" cellpadding="5" cellspacing="0">
			<tr class="claire">
     			<td class="designation">Id</td>
        		<td>&nbsp;</td>
   			</tr>
			<tr class="fonce">
       			<td class="designation">Adresse email</td>
       			<td>
       				<input type="text" class="form_long" name="email" value="" />
       			</td>
   			</tr>
			<tr class="claire">
  				<td class="designation">Nom</td>
       			<td>
       				<input type="text" class="form_long" name="name" value="" />
       			</td>
   			</tr>
			<tr class="fonce">
        		<td class="designation">Pr&eacute;nom</td>
        		<td>
        			<input type="text" class="form_long" name="prenom" value="" />
        		</td>
   			</tr>
   			<tr class="claire">
  				<td class="designation">Date</td>
       			<td>&nbsp;</td>
   			</tr>
			<tr class="fonce">
        		<td class="designation">Langue</td>
        		<td>
        			<select class="form_long" name="langue">
        			<?php
        			$dc_lang = new Lang();
        			$query_lang = 'select * from ' . $dc_lang->table;
					$resul_lang = mysql_query($query_lang);
					while($rowlang = mysql_fetch_object($resul_lang)) {
                     	echo '<option value="'. $rowlang->id .'">'.$rowlang->description.'</option>';
                   	}
        			?>
        			</select>
        		</td>
   			</tr>
			<tr class="clairebottom">
				<td class="designation">&nbsp;</td>
				<td>
					<?
 		           	if ($_POST['add']==1) {
						$email=addslashes($_POST['email']);
						$name=addslashes($_POST['name']);
						$prenom=addslashes($_POST['prenom']);
						$langue=addslashes($_POST['langue']);
						$date=date("Y-m-d H:i:s");
						$newsletter = new dc_newsletter_basic();
						// Vérification email non vide
						if ($email == "" || !isset($email)) {
							echo '<strong style="color:red;">Erreur: Le champ email est vide.</strong>';
						} else {
							// Vérification email valide
 				           	if ($newsletter->checkemail($email)) {
								// Vérification email déjà présente
								$query = "select * from $newsletter->table where email='$email'";
								$resul = mysql_query($query);
								if (mysql_num_rows($resul)>0) {
                       	        	echo '<strong style="color:red;">Erreur: L\'adresse email existe d&eacute;j&agrave;.</strong>';
                   	        	} else {
                   	        		$modif = mysql_query("INSERT INTO $newsletter->table VALUES('', '$email', '$name', '$prenom', '$langue', '$date' )");
                               		echo'<strong style="color:green;">Inscription de '.$email.' effectu&eacute;e</strong>';
                   	        	}
							} else {
								echo '<strong style="color:red;">Erreur: L\'adresse email '. $email .' n\'est pas valide</strong>';
							}
						}
					}
					?>
					&nbsp;
				</td>
			</tr>
		</table>
	</form>
</div>